package cn.zhaozhiqi.config;

import cn.zhaozhiqi.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class BootstrapListener  implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private ILoginService loginService;

	@Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if(!loginService.getAdmin("admin")){
            loginService.setAdmin();
        };
    }
}